package com.nidu.demo.security.handler;

import com.nidu.demo.common.exception.ErrorCodeConstants;
import com.nidu.demo.web.util.WebUtils;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class AuthenticationEntryPointImpl implements AuthenticationEntryPoint {
    @Override
    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) {
        WebUtils.writeJSON(response, ErrorCodeConstants.UNAUTHORIZED);
    }
}
